/**
 * 
 */
package edu.cmu.mism.dgjava.algorithm.impl;

import edu.cmu.mism.dgjava.algorithm.AbstractOptionAlgorithm;
import edu.cmu.mism.dgjava.data.models.option.BaseType;

/**
 * @author Ankit
 * 
 */
public abstract class OptionsAlg extends AbstractOptionAlgorithm {

	protected double stockPrice = 0.0; // Stock price of the given Equity
	protected double riskFreeRate = 0.0; // Risk Free Rate of the market
	protected double volatility = 0.0; // Beta or volatility of the company

	protected double strikePrice = 0.0; // Future strike price of the stock
	protected double timeToExpiration = 0.0; // Expiration time for the option

	protected BaseType type; // Indicates Put or a Call option

	protected double delta = 0.0; // Greek letter Delta
	protected double gamma = 0.0; // Greek letter Gamma
	protected double theta = 0.0; // Greek letter Theta
	protected double rho = 0.0; // Greek letter Rho
	protected double vega = 0.0; // Greek letter Vega

	/**
	 * 
	 * @param underlyingModel
	 * @param pricingModel
	 */
	public OptionsAlg(Object underlyingModel, Object pricingModel) {
		super(underlyingModel, pricingModel);

	}

	/**
	 * Calculate the option price
	 */
	protected abstract void calculateOption();


	/**
	 * Calculate all the Greek letters associated with the Company
	 */
	protected void calculateGreekLetters() {

		calculateDelta();
		calculateGamma();
		calculateTheta();
		calculateRho();
		calculateVega();

	}

	/**
	 * Calculate the Greek letter Delta
	 * 
	 * Delta: Also, referred as Hedge Ratio. The ratio comparing the change in
	 * the price of the underlying asset to the corresponding change in the
	 * price of a derivative.
	 * 
	 */
	protected abstract void calculateDelta();

	/**
	 * Calculate the Greek letter Gamma
	 * 
	 * Gamma: The rate of change for delta with respect to the underlying
	 * asset's price.
	 */
	protected abstract void calculateGamma();

	/**
	 * Calculate the Greek letter Theta
	 * 
	 * Theta: A measure of the rate of decline in the value of an option due to
	 * the passage of time. Theta can also be referred to as the time decay on
	 * the value of an option. If everything is held constant, then the option
	 * will lose value as time moves closer to the maturity of the option.
	 */
	protected abstract void calculateTheta();

	/**
	 * Calculate the Greek letter Rho
	 * 
	 * Rho: The rate at which the price of a derivative changes relative to a
	 * change in the risk-free rate of interest. Rho measures the sensitivity of
	 * an option or options portfolio to a change in interest rate.
	 */
	protected abstract void calculateRho();

	/**
	 * Calculate the Greek letter Vega
	 * 
	 * Vega: The amount that the price of an option changes compared to a 1%
	 * change in volatility.
	 */
	protected abstract void calculateVega();

	/**
	 * 
	 * @param a
	 * @param b
	 * @return the max of a and b
	 */
	protected double max(double a, double b) {

		return a > b ? a : b;
	}

}
